<template>
  <div>
    <div id="allmap" :style="option"/>
  </div>
</template>

<script>
import MP from '@/assets/js/map'
import Track from './track'

export default {
  name: 'MapTrack',
  props: {
    dataPos: Object,
    option: {
      type: Object,
      default() {
        return {
          width: '100%',
          height: '500px'
        }
      }
    }
  },
  data() {
    return {
      track: null
    }
  },
  watch: {
    dataPos(val) {
      this.track.draw(val)
    }
  },
  mounted() {
    this.init()
  },
  methods: {
    init() {
      MP().then(BMap => {
        this.track = Track.singleton()
        this.track.initMap(BMap, this.dataPos)
      })
    }
  }
}
</script>

<style scoped>
</style>
